﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
using web_api.Models;
using static System.Net.Mime.MediaTypeNames;

namespace web_api.Controllers
{
    public class ShowController : ApiController
    {
        //展示文件
        //传输各种文件列表
        public List<File> Post()
        {
            var allfile = Convert.ToInt32(HttpContext.Current.Request["allfile"]);
            string sql;
            List<File> files = new List<File>();
            List<File> filess = new List<File>();
            switch (allfile)
            {

            //所有文件
                case 1:
                    sql = $"select * from [File] where UserID=1";
                     filess = DBhelper.Show(sql, allfile,files);
                  
                    break;
                   //图片
                case 2:
                    sql = $"select * from [File] where UserID=1 and kind='图片'";
                    filess = DBhelper.Show(sql, allfile, files);
                    break;
                    //视频
                case 3:
                    sql = $"select * from [File] where UserID=1 and kind='视频'";
                    filess = DBhelper.Show(sql, allfile, files);
                    break;
                    //音频
                case 4:
                    sql = $"select * from [File] where UserID=1 and kind='音频'";
                    filess = DBhelper.Show(sql, allfile, files);
                    break;
                    //文档
                case 5:
                    sql = $"select * from [File] where UserID=1 and kind='文档'";
                    filess = DBhelper.Show(sql, allfile, files);
                    break;
            }
            return filess;
        }
    }
}
